<template>
  <div>
    <!-- 头部 -->
    <HomePannel ref="target" title="新鲜好物" subTitle="新鲜出炉 品质靠谱">
      <!-- 更多好物品 -->
      <template #right>
        <XtxMore path="/"></XtxMore>
      </template>
      <template #default>
        <!-- 公共模块 -->
        <HomeCitizen :list="newData" />
      </template>
    </HomePannel>
  </div>
</template>

<script>
import HomePannel from '../components/home-panel.vue'
import { findNew } from '@/api/home'
import { ref } from 'vue'
import { useObserbe } from '@/hook/index.js'

// 导入抽离组件
import HomeCitizen from './home-citizen.vue'
export default {
  components: {
    HomePannel,
    HomeCitizen
  },
  setup () {
    const newData = ref([])
    async function getNew () {
      const { data } = await findNew()
      newData.value = data.result
    }
    // 进入视图区域发起请求
    const { target } = useObserbe(getNew)

    return { newData, target }
  }
}
</script>

<style lang="less" scoped>
</style>
